package com.dzxcqmxm.servlet.album;

import com.dzxcqmxm.Dao.AlbumDao;
import com.dzxcqmxm.Dao.PhotoDao;
import com.dzxcqmxm.Dao.impl.AlbumDaoImpl;
import com.dzxcqmxm.Dao.impl.PhotoDaoImpl;
import com.dzxcqmxm.JB.Album;
import com.dzxcqmxm.JB.Photo;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;

/**
 * 给首页用的展示所有的公开相册
 *
 * 用户的东西并不是传到这里，而
 * 这个传过来，主要是，点击
 * 那个查看公开相册那个链接的时候先到这里。
 * 在从这里重定向到
 * 那个展示公开相册的页面
 *
 *
 */
@WebServlet("/albumFindByNameAndAlbumBaoMiServlet")
public class albumFindByNameAndAlbumBaoMiServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        AlbumDao albumDao = new AlbumDaoImpl();
        Album album = new Album();
        ArrayList<Album> albumArrayList = new ArrayList<Album>();
        /**
         * 获取查询公开相册的那个表单的提交的相册名
         */
        album.setAlbumName(new String(request.getParameter("AlbumName" ).getBytes("iso-8859-1"),"UTF-8"));

        try {
            albumArrayList = albumDao.albumFindByNameAndAlbumBaoMi(album.getAlbumName(),"0");
        } catch (Exception e) {
            e.printStackTrace();
        }

        System.out.println("打印一下处理之后的查询保密页面的albumArrayList"+albumArrayList);

        //session会话对象可以数据共享于一次会话
        request.getSession().setAttribute("albumArrayList", albumArrayList);

        //request.getSession().setAttribute("XTXCName", XTXCName);

        response.sendRedirect("/dzxc/YongHu/YongHuShouYe1.jsp");

    }

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        try {
            doPost(request, response);
        } catch (ServletException e) {
            e.printStackTrace();
        }
    }
}
